package test3_tx.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import test3_tx.dao.LogDao;
import test3_tx.service.LogService;


@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogDao logDao;


    //因为无论转账成功与否，都需要记录到日志，所以这个操作应该单独开启一个事务，而不是和transfer操作在同一个事务
    //所以通过propagation属性设定
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void log(String info) {
        logDao.log(info);
    }

}
